import 'package:cms/models/single.dart';
import 'package:cms/models/term.dart';
import 'package:flutter/material.dart';

class SearchState {
  TabController? tabController;
  // 热门分类
  List<WpTerm> hotCategory = [];
  // 猜你想看
  List<SingleModel> guessYouLike = [];
  // 搜索关键词
  TextEditingController searchKeyword = TextEditingController();
  // 搜索模式
  bool isSearch = false;
  SearchState({
    this.hotCategory = const [],
    this.guessYouLike = const [],
    this.tabController,
    TextEditingController? searchKeyword,
    this.isSearch = false,
  }) : searchKeyword = searchKeyword ?? TextEditingController();

  factory SearchState.initial() {
    return SearchState(hotCategory: [], guessYouLike: []);
  }

  SearchState clone() {
    return SearchState();
  }

  SearchState copyWith({
    List<WpTerm>? hotCategory,
    List<SingleModel>? guessYouLike,
    TabController? tabController,
    TextEditingController? searchKeyword,
    bool? isSearch,
  }) {
    return SearchState(
      hotCategory: hotCategory ?? this.hotCategory,
      guessYouLike: guessYouLike ?? this.guessYouLike,
      tabController: tabController ?? this.tabController,
      searchKeyword: searchKeyword ?? this.searchKeyword,
      isSearch: isSearch ?? this.isSearch,
    );
  }
}
